-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getEtchPacket and downloadDocuments Methods #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks sweet! Had some minor comments in the code that don't necessarily require anything to happen before I would approve.
But, there are no tests. Can you add some simple tests for these? There are some patterns for each already in the /tests
directory, and I'm happy to help you with them, too.
example/script/download-documents.js
Outdated
data.on('error', reject) | ||
writeStream.on('finish', resolve) | ||
}) | ||
console.log(statusCode, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We sure we want to write this data
to the console? It would be a lot of blah blah blah, no?
And below, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be a PassThrough stream object, but I agree it's not necessary. I'll take that out.
@@ -3,24 +3,28 @@ const defaultResponseQuery = `{ | |||
id | |||
eid | |||
name | |||
detailsURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be mindful of what's added here that may be to satisfy your example repo usage vs. what should truly be sensible defaults. If there's something you think might not reasonably belong in a default response query then let's leave it out...and if your app needs it, then it can pass its own custom response query.
I think that these are all fine in that regard, and no need to change them, but let's be mindful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed and thanks for pointing that out. I'm taking downloadZipURL
out as I don't see it being necessary.
src/index.js
Outdated
return this.requestREST( | ||
`/api/document-group/${documentGroupEid}.zip`, | ||
{ method: 'GET' }, | ||
{ dataType: DATA_TYPE_STREAM }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why default to Stream here vs Buffer (which is the default for fillPDF
? And why not allow it to be overridden to be the other type (Buffer in this case)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulted to stream since it was how I used the API in the example repo. But I've just added the option to choose between stream
and buffer
, following the approach of fillPDF
with buffer
being the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 1 small comment, and some tests and this baby is ready to go. Will approve to keep from slowing you down.
Nice!
README.md
Outdated
* Returns a `Promise` that resolves to an `Object` | ||
* `statusCode` (Number) - the HTTP status code, `200` is success | ||
* `response` (Object) - the Response object resulting from the client's request to the Anvil app | ||
* `data` (object) - a PassThrough Stream object containing the document group's data in Zip file format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should update this to be more in-line with what's now actually going to happen: buffer of stream. Probably worth following the pattern of fillPDF
and/or updating both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super minor comments and then just merge it!
README.md
Outdated
* Returns a `Promise` that resolves to an `Object` | ||
* `statusCode` (Number) - the HTTP status code, `200` is success | ||
* `response` (Object) - the Response object resulting from the client's request to the Anvil app | ||
* `data` (Buffer | Stream) - The raw binary data of the downloaded document if success. Will be in the format of either a Buffer or a Stream, depending on `dataType` option supplied to the request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `data` (Buffer | Stream) - The raw binary data of the downloaded document if success. Will be in the format of either a Buffer or a Stream, depending on `dataType` option supplied to the request. | |
* `data` (Buffer | Stream) - The raw binary data of the downloaded documents if success. Will be in the format of either a Buffer or a Stream, depending on `dataType` option supplied to the request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe even refer to the fact that they're zipped?
test/index.test.js
Outdated
}) | ||
|
||
context('unsupported options', function () { | ||
it('returns data as buffer', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('returns data as buffer', async function () { | |
it('raises appropriate error', async function () { |
Description of the change
Having the getEtchPacket method in the client would be extremely helpful for API users to be able to get their etch packet details. Because currently the only time API users are able to get etch packet details is right after they have created it. Also needed for building the signatures API example.
The downloadDocuments method hits our
/api/document-group/:documentGroupEid.zip
route specifically for client API Zip document downloads. Gives an easy abstracted solution for users to download their documents.getEtchPacket use cases:
/packet/:packetEid
route in exampledownloadDocuments use cases:
Added:
Type of change
Related issues
Checklists
Development
Code review